package com.ibangnuo.manage.controller;

import com.ibangnuo.api.AuthorizationInformationControllerApi;
import com.ibangnuo.framework.model.response.ResponseResult;
import com.ibangnuo.manage.service.AuthorizationInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: wwy
 * @Date: 2020-01-03 10:37
 */
@Controller
@RequestMapping("")
public class AuthorizationInformationController implements AuthorizationInformationControllerApi {
    @Autowired
    private AuthorizationInformationService authorizationInformationService;
    /**
     * 重定向授权接口
     * @return
     */
    @GetMapping("/authorization")
    @Override
    public String authorization() {
        String authorization = authorizationInformationService.authorization();
        return "redirect:"+authorization;
    }

    /**
     * 获取支付宝用户信息,支付宝回调地址
     * @param appId
     * @param scope
     * @param authCode
     * @return
     */
    @GetMapping("/getAuthInfo")
    @ResponseBody
    @Override
    public ResponseResult getAuthInfo(@RequestParam("app_id") String appId, @RequestParam("scope") String scope, @RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
        return authorizationInformationService.getAuthInfo(appId,scope,authCode,state);
    }
}
